package com.mfp.java.testYou.db.model;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import com.mfp.java.testYou.core.utils.FormatUtils;

public class Question extends Entity implements Serializable {

	private static final long serialVersionUID = -2693807084949861979L;

	private String text, hint;
	private List<Answer> answers;

	public final String getText() {
		return text;
	}

	public final void setText(String text) {
		this.text = text;
	}

	public final String getHint() {
		return hint;
	}

	public final void setHint(String hint) {
		this.hint = hint;
	}

	public final List<Answer> getAnswers() {
		if (answers == null) {
			answers = new LinkedList<Answer>();
		}
		return answers;
	}

	public final void setAnswers(List<Answer> answers) {
		this.answers = answers;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(FormatUtils.removeTags(text, 100));
		sb.append(" - ");
		sb.append(hint);
		sb.append(" - ");
		sb.append('[');
		for (Answer a : answers) {
			sb.append('(');
			sb.append(a.isCorect() ? 'T' : 'F');
			sb.append(") ");
			sb.append(a.getText());
			sb.append(", ");
		}
		sb.append(']');
		return sb.toString();
	}

}
